package com.solomon.travel.common.front.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.solomon.travel.common.base.controller.BaseController;
import com.solomon.travel.common.model.ApiResponse;
import com.solomon.travel.common.model.Page;
import com.solomon.travel.common.po.Announce;
import com.solomon.travel.common.po.Restaurant;
import com.solomon.travel.common.po.Shop;
import com.solomon.travel.common.service.RestaurantService;
import com.solomon.travel.common.util.ConstantUtils;
import com.solomon.travel.common.util.PageUtils;

@RestController("frontRestaurantController")
@RequestMapping("/front/restaurant")
public class RestaurantController extends BaseController {
	
	@Resource
	private RestaurantService restaurantService;
	
	@RequestMapping("/list/home")
	public ApiResponse listByHome() throws Exception {
		Page page = new Page();
		page.setBeginIndex(0);
		page.setPageSize(6);
//		List<Announce> announces = announceService.listByType(null, type, page);
		List<Restaurant> restaurants = restaurantService.listRest(page);
		return new ApiResponse(ConstantUtils.RESPONSE_CODE_OK, restaurants);
	}
	
	@RequestMapping("/list")
	public ApiResponse list(Integer pageIndex,Integer pageSize,Restaurant restaurant) {
		int restaurantCount = restaurantService.countBySerch(restaurant);
		Page page = PageUtils.createPage(pageSize, restaurantCount, pageIndex);
		List<Restaurant> restaurants = restaurantService.listBySerch(restaurant, page);
		return new ApiResponse(ConstantUtils.RESPONSE_CODE_OK, restaurants,page);
	}
}
